// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.ai.states;

import zombie.ai.State;
import zombie.characters.IsoGameCharacter;
import zombie.characters.IsoPlayer;
import zombie.core.skinnedmodel.advancedanimation.AnimEvent;

public final class PlayerEmoteState extends State {
    private static final PlayerEmoteState _instance = new PlayerEmoteState();

    public static PlayerEmoteState instance() {
        return _instance;
    }

    @Override
    public void enter(IsoGameCharacter owner) {
        owner.setVariable("EmotePlaying", true);
        owner.resetModelNextFrame();
    }

    @Override
    public void execute(IsoGameCharacter owner) {
        IsoPlayer isoPlayer = (IsoPlayer)owner;
        if (isoPlayer.pressedCancelAction()) {
            owner.setVariable("EmotePlaying", false);
        }
    }

    @Override
    public void exit(IsoGameCharacter owner) {
        owner.clearVariable("EmotePlaying");
        owner.resetModelNextFrame();
    }

    @Override
    public void animEvent(IsoGameCharacter owner, AnimEvent event) {
        if ("EmoteFinishing".equalsIgnoreCase(event.m_EventName)) {
            owner.setVariable("EmotePlaying", false);
        }

        if ("EmoteLooped".equalsIgnoreCase(event.m_EventName)) {
        }
    }

    @Override
    public boolean isDoingActionThatCanBeCancelled() {
        return true;
    }
}
